<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<link rel="stylesheet" href="../../css/layui.css">
		<script src="/js/layui/layui.all.js"></script>
		<script src="/admin/js/token.js"></script>
	</head>
	<body>
		
		<div style="margin-top: 1%;">
		  <form class="layui-form" action="">
		
		      <div class="layui-inline ">
		        <label class="layui-form-label">上线时间:</label>
		        <div class="layui-input-inline">
		          <input type="text" id="startTimeval" style="width: 220px;" lay-verify="date" autocomplete="off" class="layui-input">
		        </div>
		      </div>
		
		      <div class="layui-inline">
		        <label class="layui-form-label">下线时间:</label>
		        <div class="layui-input-inline">
		          <input type="text" id="endTimeval" lay-verify="date"  style="width: 220px;" autocomplete="off" class="layui-input">
		        </div>
		      </div>
		
		
		      <div class="layui-inline">
		        <button type="button" class="layui-btn" id="Searchbtn">搜索</button>
		      </div>
		  </form>
		</div>
		
		<table class="layui-table" id="lishidata" lay-filter="lishidata"></table>
	</body>
</html>
<script type="text/javascript">

	    var form = layui.form
	            ,layer = layui.layer
	            ,layedit = layui.layedit
	            ,laydate = layui.laydate
				,table = layui.table
				 , layer = layui.layer
				  , util = layui.util;
		  var s=layui.data("s");
		  var tid=s.terminal.terminal_id;

	 table.render({
	      elem: '#lishidata'
	      , id: "t"
	      , toolbar: "#tol"
	      , url: '/admin/terminal/query/startAndEndTime?terminalId='+tid
	      , cols: [[
	         {
	          field: 'id', title: 'ID', width: "24%",
	          align: "center"
	        }
	        ,
	        {
	          field: 'onlinetime1', title: '上线时间',
	          templet: "<div> {{  Format(d.onlinetime1,'yyyy-MM-dd hh:mm:ss')}}</div>",
	          // width: "25%",
	          align: "center"
	        }
	        , {
	          field: 'offlinetime',
			  templet: "<div> {{  Format(d.offlinetime,'yyyy-MM-dd hh:mm:ss')}}</div>",
	          // width: "24%",
	          align: "center", title: '下线时间'
	        }
	        , {
	          field: 'countTime',
	          // width: "24%",
	          align: "center", title: '在线时长(分)'
	        }
	      ]],
	      page: true
	    });

		  $("#Searchbtn").click(function(){
			  table.reload("t",{
				  where:{
					  startTime:$("#startTimeval").val(),
					  endTime:$("#endTimeval").val()
				  },
				  page:{
					  curr:1
				  }
			  });
		  });
	
	
	    //日期
	    laydate.render({
	      elem: '#startTimeval'
	      ,type: 'datetime'
	    });
	    laydate.render({
	      elem: '#endTimeval'
	      ,type: 'datetime'
	    });



</script>

<!--table日期转换格式-->
<script>
	function Format(datetime,fmt) {
		if (parseInt(datetime)==datetime) {
			if (datetime.length==10) {
				datetime=parseInt(datetime)*1000;
			} else if(datetime.length==13) {
				datetime=parseInt(datetime);
			}
		}
		datetime=new Date(datetime);
		var o = {
			"M+" : datetime.getMonth()+1,                 //月份
			"d+" : datetime.getDate(),                    //日
			"h+" : datetime.getHours(),                   //小时
			"m+" : datetime.getMinutes(),                 //分
			"s+" : datetime.getSeconds(),                 //秒
			"q+" : Math.floor((datetime.getMonth()+3)/3), //季度
			"S"  : datetime.getMilliseconds()             //毫秒
		};
		if(/(y+)/.test(fmt))
			fmt=fmt.replace(RegExp.$1, (datetime.getFullYear()+"").substr(4 - RegExp.$1.length));
		for(var k in o)
			if(new RegExp("("+ k +")").test(fmt))
				fmt = fmt.replace(RegExp.$1, (RegExp.$1.length==1) ? (o[k]) : (("00"+ o[k]).substr((""+ o[k]).length)));
		return fmt;
	}
</script>


